/*  This file is part of the comicconquer project
    Copyright (C) 2010 Reach <reach334@gmail.com>

    ComicConquer is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This software is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public 
    License along with this software.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef COGROUPBOX_H
#define COGROUPBOX_H

#include "mist.h"
#include "CoRadioButtonGroup.h"
#include "CoNumberEditor.h"
#include "CoCheckButton.h"
#include "onyx/ui/buttons.h"

/**
 * The groupbox used in setting dialog.
 * 
 * @author reach (5/25/2010)
 */
class CoGroupBox : public QGroupBox
{
    Q_OBJECT

    //-- constructor
public:
    CoGroupBox(const QString& title, QWidget* parent = 0);

    //-- public methods
public:
    void addNewLine();
    void addStretch(int stretch = 0);

    CoGroupBox* addGroupBox(const QString& name, const QString title);
    CoRadioButtonGroup* addRadioButtonGroup(const QString& name, const QStringList& texts);
    CoCheckButton* addCheckButton(const QString& name, const QString& text);
    CoNumberEditor* addNumberEditor(const QString& name, const QString& text, const QString& unit, float max, float rate = 1.0f);
    ui::OnyxPushButton* addPushButton(const QString& name, const QString& text);

    CoGroupBox* getGroupBox(const QString& name);
    CoRadioButtonGroup* getRadioButtonGroup(const QString& name);
    CoCheckButton* getCheckButton(const QString& name);
    CoNumberEditor* getNumberEditor(const QString& name);

    //-- private members
private:
    QVBoxLayout m_layout;
    QHBoxLayout* m_curLayout;
    QMap<QString, QWidget*> m_widgetMap;
    QVector<QWidget*> m_widgetVec;
    int m_curFocusWidget;
};

#endif // COGROUPBOX_H
